<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增水电师傅')" />
</head>
<body>
    <div class="main-content">
        <div class="col-md-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">水电师傅名称：</label>
                <div class="col-sm-9">
                    <input type="text" id="userName" class="form-control" placeholder="请输入文本">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">联系方式：</label>
                <div class="col-sm-9">
                    <input type="text" id="phonenumber" class="form-control" placeholder="请输入文本">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注信息：</label>
                <div class="col-sm-9">
                    <textarea type="text" id="remark" class="form-control" placeholder="请输入文本"></textarea>
                </div>
            </div>
            <div class="form-group">
                <p>&nbsp;</p>
            </div>
        </div>
    </div>
    <div class="row col-sm-12">
        <div class="col-sm-8 pull-right">
            <button type="button" class="btn btn-primary" onclick="addSave()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-danger" onclick="$.modal.close()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
	<th:block th:include="include :: footer" />
	<script>
	   function addSave() {
           if($("#phonenumber").val().length < 7){
               $.modal.msgError('输入正确的联系方式');
                return false;
           }
           $.ajax({
               type: "post",
               url: ctx + "hh/user/workerAdd",
               data: {
                   "userName": $("#userName").val(),
                   "phonenumber": $("#phonenumber").val(),
                   "remark": $("#remark").val(),
               },
               success: function(r) {
                   if (r.code == 0) {
                       $.modal.close();
                   } else {
                       $.modal.closeLoading();
                       $('.imgcode').click();
                       $(".code").val("");
                       $.modal.msg(r.msg);
                   }
               }
           })
       }

    </script>
</body>
</html>